snapshot: Add gtk_snapshot_push_color_matrix()
authorBenjamin Otte <otte@redhat.com>
Sat, 31 Dec 2016 00:14:59 +0000 (01:14 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 31 Dec 2016 01:49:47 +0000 (02:49 +0100)
So far, this is unused.

docs/reference/gtk/gtk4-sections.txt
gtk/gtksnapshot.c
gtk/gtksnapshot.h

index d2faa2c8b75ee226ddccf8957fa800c1dbf41500..e3d3bd24db81cb1402992163366bf231542bc108 100644 (file)
@@ -4457,6 +4457,8 @@ GtkSnapshot
 gtk_snapshot_push
 gtk_snapshot_push_node
 gtk_snapshot_push_transform
+gtk_snapshot_push_opacity
+gtk_snapshot_push_color_matrix
 gtk_snapshot_push_clip
 gtk_snapshot_push_rounded_clip
 gtk_snapshot_pop
index d85a43d21f31f399c687ffa298c458460910329d..f604872cf47af9deb91ce9d308e6b9e6c2c705f7 100644 (file)
@@ -295,6 +295,12 @@ gtk_snapshot_collect_opacity (GskRenderNode **nodes,
   return opacity_node;
 }
 
+typedef struct _ColorMatrix ColorMatrix;
+struct _ColorMatrix {
+  graphene_matrix_t matrix;
+  graphene_vec4_t offset;
+};
+
 void
 gtk_snapshot_push_opacity (GtkSnapshot *snapshot,
                            double       opacity,
@@ -326,6 +332,64 @@ gtk_snapshot_push_opacity (GtkSnapshot *snapshot,
                                             real_opacity);
 }
 
+static GskRenderNode *
+gtk_snapshot_collect_color_matrix (GskRenderNode **nodes,
+                                   guint           n_nodes,
+                                   const char     *name,
+                                   gpointer        data)
+{
+  ColorMatrix *color_matrix = data;
+  GskRenderNode *node, *color_matrix_node;
+
+  node = gtk_snapshot_collect_default (nodes, n_nodes, name, NULL);
+  if (node == NULL)
+    return NULL;
+
+  color_matrix_node = gsk_color_matrix_node_new (node,
+                                                 &color_matrix->matrix,
+                                                 &color_matrix->offset);
+  gsk_render_node_set_name (color_matrix_node, name);
+
+  gsk_render_node_unref (node);
+  g_free (color_matrix);
+
+  return color_matrix_node;
+}
+
+void
+gtk_snapshot_push_color_matrix (GtkSnapshot             *snapshot,
+                                const graphene_matrix_t *color_matrix,
+                                const graphene_vec4_t   *color_offset,
+                                const char              *name,
+                                ...)
+{
+  ColorMatrix *color_matrix_data;
+  char *str;
+
+  if (name)
+    {
+      va_list args;
+
+      va_start (args, name);
+      str = g_strdup_vprintf (name, args);
+      va_end (args);
+    }
+  else
+    str = NULL;
+
+  color_matrix_data = g_new (ColorMatrix, 1);
+  graphene_matrix_init_from_matrix (&color_matrix_data->matrix, color_matrix);
+  graphene_vec4_init_from_vec4 (&color_matrix_data->offset, color_offset);
+
+  snapshot->state = gtk_snapshot_state_new (snapshot->state,
+                                            str,
+                                            snapshot->state->clip_region,
+                                            snapshot->state->translate_x,
+                                            snapshot->state->translate_y,
+                                            gtk_snapshot_collect_color_matrix,
+                                            color_matrix_data);
+}
+
 static void
 rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
                               const graphene_rect_t *graphene)
index 22a12a352747088bc025eb5d72a44c1c099973cc..e7b35b87a33ac1759b1a7b89b716773cbb2eb985 100644 (file)
@@ -52,6 +52,12 @@ void            gtk_snapshot_push_opacity               (GtkSnapshot
                                                          const char             *name,
                                                          ...) G_GNUC_PRINTF (3, 4);
 GDK_AVAILABLE_IN_3_90
+void            gtk_snapshot_push_color_matrix          (GtkSnapshot            *snapshot,
+                                                         const graphene_matrix_t*color_matrix,
+                                                         const graphene_vec4_t  *color_offset,
+                                                         const char             *name,
+                                                         ...) G_GNUC_PRINTF (4, 5);
+GDK_AVAILABLE_IN_3_90
 void            gtk_snapshot_push_clip                  (GtkSnapshot            *snapshot,
                                                          const graphene_rect_t  *bounds,
                                                          const char             *name,